import request from '/@/utils/request';

export function useDeptApi() {
	return {
		// 查询部门列表
		listDept: (query: any) => {
			return request({
				url: '/system/dept/list',
				method: 'get',
				params: query,
			});
		},
		// 查询部门列表（排除节点）
		listDeptExcludeChild: (deptId: any) => {
			return request({
				url: '/system/dept/list/exclude/' + deptId,
				method: 'get',
			});
		},
		// 查询部门详细
		getDept: (deptId: any) => {
			return request({
				url: '/system/dept/get?id=' + deptId,
				method: 'get',
			});
		},
		// 查询部门下拉树结构
		treeselect: () => {
			return request({
				url: '/system/dept/treeselect',
				method: 'get',
			});
		},
		// 获取部门精简信息列表
		listSimpleDepts: () => {
			return request({
				url: '/system/dept/list-all-simple',
				method: 'get',
			});
		},
		// 新增部门
		addDept: (data: any) => {
			return request({
				url: '/system/dept',
				method: 'post',
				data: data,
			});
		},
		// 修改部门
		updateDept: (data: any) => {
			return request({
				url: '/system/dept',
				method: 'put',
				data: data,
			});
		},
		// 删除部门
		delDept: (deptId: string) => {
			return request({
				url: '/system/dept/' + deptId,
				method: 'delete',
			});
		},
	};
}
